package view.salas;

import java.awt.Color;
import java.awt.Component;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

public class FormatoNombreCursada extends DefaultTableCellRenderer {
	private static final long serialVersionUID = 1L;
//	private int columna_patron;
//	private int fila;
//	private Set<String> cursadasNombre;
	private String nombre;
	private int i;

	public FormatoNombreCursada(String nombre, int i) {
//		this.columna_patron = Colpatron;
//		this.fila = fila;
//		this.cursadasNombre = cursadasNombre;
		this.nombre = nombre;
		this.i = i;
	}

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value, boolean selected, boolean focused, int row, int column) {
		JLabel cell = (JLabel) super.getTableCellRendererComponent(table, value, selected, focused, row, column);
		cell.setBackground(Color.white);// color de fondo
		table.setForeground(Color.black);// color de texto
		// Si la celda corresponde a una fila con estado FALSE, se cambia el color de fondo a rojo

		// en caso de que falle crear jlabel []
//		JLabel[] cells = new JLabel[cursadasNombre.size()];
		Color[] colores = cargarColores();
//		int i = 0;
//		for (String nombre : cursadasNombre) {
			if (value != null) {
				if (value.equals(nombre)) {
					// if (column == columna_patron) {
//					Color color = new Color(255, 200, 0);
					cell.setBackground(colores[i]);
//					i++;

					// }

				}
			}
			 else {
					table.setBackground(new Color(255, 255, 255));// EL COLOR DEL RESTO DE LAS COLUMNAS
				}
//		}
		// if (table.getValueAt(row, columna_patron).equals("ASISTENTE CONTABLE")) {
		// for (int i = 0; i < horas; i++) {
		//
		// if (column == columna_patron) {
		// Color color = new Color(255, 200, 0);
		// cell.setBackground(color);
		// }
		//
		// if (i != 0) {
		// if (row == fila + i && column == columna_patron) {
		// Color color = new Color(255, 200, 0);
		// cell.setBackground(color);
		// }
		// }
		// }
		// }

		// super.getTableCellRendererComponent(table, value, selected, focused, row, column);
		return cell;
	}

	// public Map<Color, String> paletaColores(Set<String> cursadas) {
	// Map colorCursada = new HashMap<Color, String>();
	// Color[] colores = cargarColores();
	// for (int i = 0; i < cursadas.size(); i++) {
	// for (String nombreC : cursadas) {
	// colorCursada.put(colores[i], value)
	// }
	// }
	// }

	public Color[] cargarColores() {
		Color[] colores = new Color[46];

		colores[0] = new Color(0, 0, 255);
		colores[1] = new Color(138, 43, 226);
		colores[2] = new Color(165, 42, 42);
		colores[3] = new Color(222, 184, 135);
		colores[4] = new Color(95, 158, 160);
		colores[5] = new Color(127, 255, 0);
		colores[6] = new Color(210, 105, 30);
		colores[7] = new Color(255, 127, 80);
		colores[8] = new Color(100, 149, 237);
		colores[9] = new Color(255, 248, 220);
		colores[10] = new Color(220, 20, 54);
		colores[11] = new Color(0, 0, 139);
		colores[12] = new Color(0, 139, 139);
		colores[13] = new Color(184, 134, 11);
		colores[14] = new Color(169, 169, 169);
		colores[15] = new Color(0, 100, 0);
		colores[16] = new Color(189, 183, 107);
		colores[17] = new Color(139, 0, 139);
		colores[18] = new Color(85, 107, 47);
		colores[19] = new Color(255, 140, 0);
		colores[20] = new Color(255, 215, 0);
		colores[21] = new Color(218, 165, 32);
		colores[22] = new Color(128, 128, 128);
		colores[23] = new Color(173, 255, 47);
		colores[24] = new Color(240, 255, 240);
		colores[25] = new Color(255, 105, 180);
		colores[26] = new Color(0, 255, 0);
		colores[27] = new Color(50, 205, 50);
		colores[28] = new Color(60, 179, 113);
		colores[29] = new Color(123, 104, 238);
		colores[30] = new Color(0, 250, 154);
		colores[31] = new Color(72, 209, 204);
		colores[32] = new Color(128, 0, 128);
		colores[33] = new Color(255, 0, 0);
		colores[34] = new Color(188, 143, 143);
		colores[35] = new Color(0, 255, 127);
		colores[36] = new Color(70, 130, 180);
		colores[37] = new Color(210, 180, 140);
		colores[38] = new Color(0, 128, 128);
		colores[39] = new Color(216, 191, 216);
		colores[40] = new Color(255, 99, 71);
		colores[41] = new Color(64, 224, 208);
		colores[42] = new Color(238, 130, 238);
		colores[43] = new Color(245, 222, 179);
		colores[44] = new Color(0, 128, 0);
		colores[45] = new Color(0, 255, 255);

		return colores;

	}
	// blue (0,0,255) #0000FF
	// blueviolet (138,43,226) #8A2BE2
	// brown (165,42,42) #A52A2A
	// burlywood (222,184,135) #DEB887
	// cadetblue (95,158,160) #5F9EA0
	// chartreuse (127,255,0) #7FFF00
	// chocolate (210,105,30) #D2691E
	// coral (255,127,80) #FF7F50
	// cornflowerblue (100,149,237) #6495ED
	// cornsilk (255,248,220) #FFF8DC
	// crimson (220,20,54) #DC1436
	// cyan (0,255,255) #00FFFF
	// darkblue (0,0,139) #00008B
	// darkcyan (0,139,139) #008B8B
	// darkgoldenrod (184,134,11) #B8860B
	// darkgray (169,169,169) #A9A9A9
	// darkgreen (0,100,0) #006400
	// darkkhaki (189,183,107) #BDB76B
	// darkmagenta (139,0,139) #8B008B
	// darkolivegreen (85,107,47) #556B2F
	// darkorange (255,140,0) #FF8C00

	// gold (255,215,0) #FFD700
	// goldenrod (218,165,32) #DAA520
	// gray (128,128,128) #808080
	// green (0,128,0) #008000
	// greenyellow (173,255,47) #ADFF2F
	// honeydew (240,255,240) #F0FFF0
	// hotpink (255,105,180) #FF69B4

	// lime (0,255,0) #00FF00
	// limegreen (50,205,50) #32CD32
	// mediumseagreen (60,179,113) #3CB371
	// mediumslateblue (123,104,238) #7B68EE
	// mediumspringgreen (0,250,154) #00FA9A
	// mediumturquoise (72,209,204) #48D1CC

	// purple (128,0,128) #800080
	// red (255,0,0) #FF0000
	// rosybrown (188,143,143) #BC8F8F

	// springgreen (0,255,127) #00FF7F
	// steelblue (70,130,180) #4682B4
	// tan (210,180,140) #D2B48C
	// teal (0,128,128) #08080
	// thistle (216,191,216) #D8BFD8
	// tomato (255,99,71) #FF6347
	// turquoise (64,224,208) #40E0D0
	// violet (238,130,238) #EE82EE
	// wheat (245,222,179) #F5DEB3

}
